package studysystem.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MySQLConnector {
        private static String   JDBC_DRIVER     = "com.mysql.jdbc.Driver";
        private static String   DB_PATH         = "jdbc:mysql://localhost/cpp_manual";
        private static String   USER            = "root";
        private static String   PASSWORD        = "44morning44";

        private Connection              conn            = null;

        public MySQLConnector() throws Exception {
                Class.forName(JDBC_DRIVER);
                conn = DriverManager.getConnection(String.format("%s?user=%s&password=%s", DB_PATH, USER, PASSWORD));
        }

        public ResultSet execSQLQuery(String query) throws SQLException {
                Statement statement = conn.createStatement();
                return statement.executeQuery(query);
        }

		public int execSQLUpdate(String query) throws SQLException {
			 Statement statement = conn.createStatement();
             return statement.executeUpdate(query);
			
		}
}
